import {
	get,
	post,
	put,
	del,
} from "./http.js";

const Api = {
	Plan: {
		Store: (params) => post(`/api/plan/store`, params),
		Del: (id) => del(`/api/plan/${id}`),
		Detail: (id) => get(`/api/plan/${id}`),
		Update: (id, params) => put(`/api/plan/${id}`, params),
		Date: {
			List: (id, params) => get(`/api/plan/${id}/punch`, params)
		},
		Active: {
			List: (id, params) => get(`/api/plan/${id}/fragments`, params),
			Add: (params) => post(`/api/plan-fragment/store`, params),
			Del: (id) => del(`/api/plan-fragment/${id}`),
			Detail: (id) => get(`/api/plan-fragment/${id}`),
			Update: (id, params) => put(`/api/plan-fragment/${id}`, params),
		}
	},
	Shop: {
		Member: (params) => post(`/backend/api/member`, params),
		Order: (params) => post(`/backend/api/order`, params),
		Recharge: (params) => post(`/backend/api/order/transfer`, params),
		Product: {
			List: (params) => post(`/backend/api/product`, params),
			Detail: (id) => get(`/backend/api/product/${id}`),
			Del: (id) => del(`/backend/api/product/${id}`),
		},
		Image: {
			List: (params) => post(`/backend/api/image`, params),
			Del: (id) => del(`/backend/api/image/${id}`),
		},
		Video: {
			List: (params) => post(`/backend/api/video`, params),
			Del: (id) => del(`/backend/api/video/${id}`),
		},
		Conquer: {
			List: (params) => get(`/api/conquer`, params),
			Del: (id) => del(`/api/conquer/${id}`),
			Notice: (id) => get(`/api/conquer/${id}/notice`),
			
		},
	},
	Appraise: {
		List: (type, id, params) => get(`/api/appraise/${type}/${id}`, params),
	},
	Order: {
		Detail: (id) => get(`/api/order/${id}`),
		Cancel: (id) => put(`/api/order/${id}/cancel`),
		Address: (id, params) => put(`/api/order/${id}/address`, params)

	},
	Product: {
		Order: (params) => post(`/api/order/product`, params),
		List: (params) => get(`/api/product`, params),
		Detail: (id) => get(`/api/product/${id}`),

	},
	address: {
		getCity: (parms = {}) => get(`/api/location/cities`, parms), //获取城市
		getDetail: () => get(`/api/address/detail`),
		getRrovince: (parms = {}) => get(`/api/location/provinces`, parms), //获取省份
		getDistricts: (parms = {}) => get(`/api/location/districts`, parms), //获取区
		getStreets: (parms = {}) => get(`/api/location/streets`, parms), //获取街道
		add: (params) => post(`/api/address/store`, params), //添加地址
		put: (id, params) => put(`/api/address/${id}`, params), //修改地址
		detail: (id) => get(`/api/address/${id}`), //获取详情,
		delete: (id) => del(`/api/address/${id}/delete`)
	},
	Home: {
		List: (params) => get(`/api/home`, params),
	},
	Run: {
		Del: (id) => del(`/api/run/${id}`),
		Detail: (id) => get(`/api/run/${id}/detail`),
		Add: (params) => post(`/api/run/store`, params),
		Red_packet: (id, user_id, params) => get(`/api/run/${id}/user/${user_id}/red_packet`, params),
		Reply: (id, params) => put(`/api/run/red_packet/reply/${id}`, params),
	},
	Step: {
		Step: (params) => get('/api/my/step', params)
	},
	Recharge: {
		Recharge: (params) => post(`/api/order/recharge`, params),
		Payment: (params) => post(`/api/order/payment/wechat/mini/recharge`, params)
	},
	Relative: {
		Add: (params) => post(`/api/my/relative/store`, params),
		List: (params) => post(`/api/my/relative`, params),
		Del: (id) => del(`/api/my/relative/${id}`),
		Update: (id, params) => put(`/api/my/relative/${id}`, params),
		Run: {
			Add: (params) => post(`/api/run/receiver/store`, params),
			Del: (id) => del(`/api/run/receiver/${id}`),
			Detail: (id) => get(`/api/run/receiver/${id}`),
			Update: (id, params) => put(`/api/run/receiver/${id}`, params),
		}
	},
	Thumbsup: {
		Thumbsup: (type, id, params) => post(`/api/thumbsup/${type}/${id}`, params),
	},
	Followed: {
		Follow(params) {
			return post("/api/my/follow", params);
		},
		DelFollow(params) {
			return del("/api/my/unfollow", params);
		},
	},
	Edit: {
		Nickname: (params) => post(`/api/my/detail/nickname`, params),
		Update: (params) => post(`/api/my/profile`, params),
	},
	User: {
		Send: (params) => get(`/api/user/send`, params),
		Run: (id, params) => get(`/api/user/${id}/run`, params),
		Relative: (id, params) => get(`/api/user/${id}/relative`, params),
		Trend: (user_id, conquer_id, params) => get(
			`/api/user/${user_id}/conquer/${conquer_id}/weight-fragment/trend`,
			params),
		Conquer: (user_id, conquer_id) => get(`/api/user/${user_id}/conquer/${conquer_id}`),
		Detail: (id) => get(`/api/user/${id}/detail`),
		Active: (user_id, conquer_id, params) => get(`/api/user/${user_id}/conquer/${conquer_id}/weight-fragment`,
			params),
		Images: (user_id, conquer_id, params) => get(
			`/api/weight-fragment/user/${user_id}/conquer/${conquer_id}/images`,
			params),
		ConquerList: (id, params) => get(`/api/user/${id}/conquers`, params),
		Fragments: (id, params) => get(`/api/user/${id}/fragments`, params),
		Family: (id, params) => get(`/api/user/${id}/family`, params),
	},
	Image: {
		Update: (id, params) => put(`/api/image/${id}`, params),
	},
	Video: {
		Add: (params) => post(`/api/video/store`, params),
		Del: (id) => del(`/api/video/${id}`),
	},
	Active: {
		Update: (id, params) => put(`/api/weight-fragment/${id}`, params),
		Detail: (id) => get(`/api/weight-fragment/${id}`),
		Del: (id) => del(`/api/weight-fragment/${id}`),
		List: (id, params) => get(`/api/conquer/${id}/fragment`, params),
		AllList: (params) => get(`/api/my/feed`, params),
		Add: (params) => post(`/api/weight-fragment/store`, params),
		Rank: {
			List: (params) => get(`/api/weight-fragment/rank`, params)
		},
		Latest: (id) => get(`/api/conquer/${id}/latest`),

	},
	District: {
		Add: (params) => post(`/api/district/store`, params),
		Nearby: (params) => get(`/api/district/nearby`, params),
	},
	Conquer: {
		List: (params) => get(`/api/conquer`, params),
		Detail: (id) => get(`/api/conquer/${id}`),
		Add: (id, params) => post(`/api/conquer/${id}/attend`, params),
		Store: (params) => post(`/api/conquer/store`, params),
		User: (id, params) => get(`/api/conquer/${id}/user`, params),
		Del: (id) => del(`/api/conquer/${id}`),
		Info: (id) => get(`/api/conquer/${id}`),
		Update: (id, params) => put(`/api/conquer/${id}`, params),
		UnAdd: (id) => del(`/api/conquer/${id}/quit`),
		Record: {
			Update: (id, params) => put(`/api/conquer/record/${id}`, params),
		},
		Date: {
			List: (conquer_id, params) => get(`/api/conquer/${conquer_id}/punch`, params)
		},
	},
	My: {
		Redpacket: (params) => get(`/api/my/redpacket`, params),
		Plan: (params) => get(`/api/my/plan`, params),
		Fragment: (params) => get(`/api/my/fragment`, params),
		Fulfill: (params) => get(`/api/my/fulfill`, params),
		Point: {
			List: (params) => get(`/api/my/point`, params),
			Add: (params) => post(`/api/point/store`, params),
			Del: (id) => del(`/api/point/${id}`),
			Detail: (id) => get(`/api/point/${id}`),
			Update: (id, params) => put(`/api/point/${id}`, params),
		},
		Family: {
			List: (params) => get(`/api/my/family`, params),
			Del: (id) => del(`/api/my/family/${id}`),
			Add: (params) => post(`/api/family/store`, params),
			Member: {
				Add: (id, params) => post(`/api/family/${id}/member/store`, params),
				AddUser: (id, params) => post(`/api/family/${id}/member/create`, params),
				Del: (id, user_id) => del(`/api/family/${id}/member/${user_id}`)
			}
		},
		Orders(params) {
			return get(`/api/my/orders`, params);
		},
		OrderRecharge(params) {
			return get(`/api/my/order/recharge`, params);
		},

		AddressTag: () => get(`/api/my/address/tag`),
		addresses: () => get(`/api/my/address`),
		notificationMarkAllAsRead() {
			return get(`/api/my/notification/all`)
		},
		notificationMarkAsRead(id) {
			return get("/api/my/notification/" + id)
		},
		message(params) {
			return get("/api/my/message", params)
		},
		BlessingRecord: (params) => get(`/api/my/blessing/record`, params),
		BlessingBalance: (params) => get(`/api/my/blessing/balance`, params),
		Blessing: (params) => get(`/api/my/blessing`, params),
		Wish: (params) => get(`/api/my/wish`, params),
		Reward: (params) => get(`/api/my/reward`, params),
		Record: (params) => get('/api/my/conquer/record', params),
		Follower(params) {
			return get("/api/my/followers", params);
		},
		Followings(params) {
			return post("/api/my/followings", params);
		},
		Detail: () => get('/api/my/detail'),
		Conquer: (params) => get('/api/my/conquer', params),
		District: () => get('/api/my/district'),
		Active: () => get('/api/my/feed'),
		Run: (params) => get('/api/my/run', params),
		Balance: (params) => get(`/api/my/recharge/balance`, params),
	},
	Login: {
		SendSms(params) {
			return post(`/api/captcha/sms`, params);
		},
		/* 手机号登录 */
		Mobile(params) {
			return post(`/api/login/mini/mobile`, params);
		},
		/* 静默登录 */
		Silent(params) {
			return post(`/api/login/mini/silent`, params);
		},
		/* 获取openid和session*/
		Session(params) {
			return post(`/api/login/mini/session`, params);
		},
		SmsLogin(params) {
			return post(`/api/login/mobile`, params);
		},
		PasswordLogin(params) {
			return post(`/api/login/password`, params);
		},
		WechatMiniLogin(params) {
			return post(`/api/wechat/mini/login`, params);
		},
	},
	Aliyun: {
		Video: {
			Create: (params) => post(`/api/aliyun/video/token/create`, params)
		}
	},
	Image: {
		Add: (id, params) => post(`/api/weight-fragment/${id}/image/store`, params),
		Del: (id) => del(`/api/image/${id}`),
	},
	Reward: {
		List: (params) => get(`/api/reward`, params),
		Add: (params) => post(`/api/reward/store `, params),
		Del: (id) => del(`/api/reward/${id}`),
		Update: (id, params) => put(`/api/reward/${id}`, params),
	},
	Wish: {
		Add: (params) => post(`/api/wish/store `, params),
		Del: (id) => del(`/api/wish/${id}`),
		Update: (id, params) => put(`/api/wish/${id}`, params),
		Detail: (id) => get(`/api/wish/${id}/detail`),
		Info: (id) => get(`/api/wish/${id}`),
		Active: {
			Update: (id, params) => put(`/api/wish-fragment/${id}`, params),
			Detail: (id) => get(`/api/wish-fragment/${id}`),
			Del: (id) => del(`/api/wish-fragment/${id}`),
			List: (id, params) => get(`/api/wish/${id}/fragments`, params),
			Add: (params) => post(`/api/wish-fragment/store`, params),
		},
	},
	Comment: {
		List: (type,id, params) => get(`/api/comment/${type}/${id}`, params),
		Add: (type,id, params) => post(`/api/comment/${type}/${id}/submit`, params),
		ListReply: (id, params) => get(`/api/comment/${id}/answer`, params),
	}

};

export default Api;